<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">




  
  
    
      
    
    
      
    
  <script src="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/pace.min.js"></script>
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/pace/1.0.2/themes/blue/pace-theme-minimal.min.css">

















  
  
    
  
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.6/jquery.fancybox.min.css">







  

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.2/css/font-awesome.min.css">

<link rel="stylesheet" href="/css/main.css?v=6.7.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.7.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.7.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.7.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.7.0" color="#222">







<script id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '6.7.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    fastclick: true,
    lazyload: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta property="og:type" content="website">
<meta property="og:title" content="旅行者">
<meta property="og:url" content="https://lvsmart.cn/index.html">
<meta property="og:site_name" content="旅行者">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="旅行者">






  <link rel="canonical" href="https://lvsmart.cn/">



<script id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>旅行者</title>
  












  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">旅行者</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home menu-item-active">

    
    
    
      
    

    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">

    
    
    
      
    

    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">

    
    
    
      
    

    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">

    
    
    
      
    

    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>

      
      
    </ul>
  

  
    

  

  
</nav>



  



</div>
    </header>

    
  
  
  
  

  

  <a href="https://github.com/lvsmart" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewbox="0 0 250 250" style="fill: #222; color: #fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a>



    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/08/23/accessToken/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/08/23/accessToken/" class="post-title-link" itemprop="url">accessToken</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-08-23 09:50:19" itemprop="dateCreated datePublished" datetime="2019-08-23T09:50:19+08:00">2019-08-23</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-10-12 19:50:11" itemprop="dateModified" datetime="2019-10-12T19:50:11+08:00">2019-10-12</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/开发/" itemprop="url" rel="index"><span itemprop="name">开发</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/08/23/accessToken/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/08/23/accessToken/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/08/23/accessToken/" class="leancloud_visitors" data-flag-title="accessToken">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="accessToken"><a href="#accessToken" class="headerlink" title="accessToken"></a>accessToken</h1><ul>
<li>使用企业微信的API，必须带有accessToken</li>
<li>accessToken由appid和secret生成，生成之后有效期2小时，每天调用次数受限</li>
</ul>
<h1 id="简单方案"><a href="#简单方案" class="headerlink" title="简单方案"></a>简单方案</h1><ul>
<li>不能每次调用接口，都生成accessToken。</li>
<li>生成的accessToken进行缓存，token过期了，再去生成</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="keyword">import</span> logging</span><br><span class="line"><span class="keyword">import</span> math</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">from</span> urllib.parse <span class="keyword">import</span> urlencode</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> requests</span><br><span class="line"><span class="keyword">from</span> django.core.cache <span class="keyword">import</span> cache</span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> roster.models <span class="keyword">import</span> CorpInfo</span><br><span class="line"></span><br><span class="line">logger = logging.getLogger(<span class="string">'django'</span>)</span><br><span class="line">response_logger = logging.getLogger(<span class="string">'response'</span>)</span><br><span class="line">BASE_URL = <span class="string">'https://qyapi.weixin.qq.com/cgi-bin/'</span></span><br><span class="line">CORPINFO_NAME = <span class="string">'weixin'</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">refresh_token</span><span class="params">()</span>:</span></span><br><span class="line">    logger.warning(<span class="string">'refresh weixin token'</span>)</span><br><span class="line">    url = BASE_URL + <span class="string">'gettoken'</span></span><br><span class="line">    corp_info = CorpInfo.objects.get(name=CORPINFO_NAME)</span><br><span class="line">    payload = &#123;</span><br><span class="line">        <span class="string">'corpid'</span>: corp_info.corp_id,</span><br><span class="line">        <span class="string">'corpsecret'</span>: corp_info.corp_secret</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    token_response = requests.get(url, params=payload).json()</span><br><span class="line">    access_token = token_response.get(<span class="string">'access_token'</span>)</span><br><span class="line">    expire_time = token_response.get(<span class="string">'expires_in'</span>)</span><br><span class="line">    cache_key = corp_info.corp_id + corp_info.corp_secret</span><br><span class="line"></span><br><span class="line">    cache.set(cache_key, access_token, expire_time)</span><br><span class="line">    <span class="keyword">return</span> access_token</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">retry</span><span class="params">(tries, delay=<span class="number">3</span>, backoff=<span class="number">2</span>)</span>:</span></span><br><span class="line">    <span class="keyword">if</span> backoff &lt;= <span class="number">1</span>:</span><br><span class="line">        <span class="keyword">raise</span> ValueError(<span class="string">"backoff must be greater than 1"</span>)</span><br><span class="line"></span><br><span class="line">    tries = math.floor(tries)</span><br><span class="line">    <span class="keyword">if</span> tries &lt; <span class="number">0</span>:</span><br><span class="line">        <span class="keyword">raise</span> ValueError(<span class="string">"tries must be 0 or greater"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> delay &lt;= <span class="number">0</span>:</span><br><span class="line">        <span class="keyword">raise</span> ValueError(<span class="string">"delay must be greater than 0"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">deco_retry</span><span class="params">(f)</span>:</span></span><br><span class="line">        <span class="function"><span class="keyword">def</span> <span class="title">f_retry</span><span class="params">(*args, **kwargs)</span>:</span></span><br><span class="line">            mtries, mdelay = tries, delay  <span class="comment"># make mutable</span></span><br><span class="line"></span><br><span class="line">            rv = f(*args, **kwargs)  <span class="comment"># first attempt</span></span><br><span class="line">            <span class="keyword">while</span> mtries &gt; <span class="number">0</span>:</span><br><span class="line">                <span class="keyword">if</span> rv.get(<span class="string">'errcode'</span>) == <span class="number">0</span>:</span><br><span class="line">                    <span class="keyword">return</span> rv</span><br><span class="line"></span><br><span class="line">                <span class="keyword">if</span> rv.get(<span class="string">'errcode'</span>) == <span class="number">40014</span>:</span><br><span class="line">                    <span class="comment"># 如果token过期，重新获取</span></span><br><span class="line">                    logger.warning(rv)</span><br><span class="line">                    refresh_token()</span><br><span class="line"></span><br><span class="line">                    mtries -= <span class="number">1</span>  <span class="comment"># consume an attempt</span></span><br><span class="line">                    time.sleep(mdelay)  <span class="comment"># wait...</span></span><br><span class="line">                    mdelay *= backoff  <span class="comment"># make future wait longer</span></span><br><span class="line"></span><br><span class="line">                    rv = f(*args, **kwargs)  <span class="comment"># Try again</span></span><br><span class="line"></span><br><span class="line">                    <span class="keyword">return</span> rv  <span class="comment"># Ran out of tries :-(</span></span><br><span class="line">                <span class="keyword">return</span> rv</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> f_retry  <span class="comment"># true decorator -&gt; decorated function</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> deco_retry  <span class="comment"># @retry(arg[, ...]) -&gt; true decorator</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">WeixinRequest</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self)</span>:</span></span><br><span class="line">        self.session = requests.Session()</span><br><span class="line"></span><br><span class="line"><span class="meta">    @retry(3)</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get</span><span class="params">(self, path, params=None)</span>:</span></span><br><span class="line">        corp_info = CorpInfo.objects.get(name=CORPINFO_NAME)</span><br><span class="line">        cache_key = corp_info.corp_id + corp_info.corp_secret</span><br><span class="line">        access_token = cache.get(cache_key)</span><br><span class="line">        logger.info(access_token)</span><br><span class="line">        <span class="keyword">if</span> access_token <span class="keyword">is</span> <span class="keyword">None</span>:</span><br><span class="line">            access_token = refresh_token()</span><br><span class="line">        <span class="keyword">if</span> params <span class="keyword">is</span> <span class="keyword">None</span>:</span><br><span class="line">            params = &#123;&#125;</span><br><span class="line">        params.update(&#123;<span class="string">'access_token'</span>: access_token&#125;)</span><br><span class="line">        url = BASE_URL + path + <span class="string">'?'</span> + urlencode(params)</span><br><span class="line">        logger.info(url)</span><br><span class="line">        response = self.session.get(url).json()</span><br><span class="line">        response_logger.info(response)</span><br><span class="line">        <span class="keyword">return</span> response</span><br><span class="line"></span><br><span class="line"><span class="meta">    @retry(3)</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">post</span><span class="params">(self, path, payload)</span>:</span></span><br><span class="line">        corp_info = CorpInfo.objects.get(name=CORPINFO_NAME)</span><br><span class="line">        cache_key = corp_info.corp_id + corp_info.corp_secret</span><br><span class="line">        access_token = cache.get(cache_key)</span><br><span class="line">        logger.info(access_token)</span><br><span class="line">        <span class="keyword">if</span> access_token <span class="keyword">is</span> <span class="keyword">None</span>:</span><br><span class="line">            access_token = refresh_token()</span><br><span class="line">        params = &#123;&#125;</span><br><span class="line">        params.update(&#123;<span class="string">'access_token'</span>: access_token&#125;)</span><br><span class="line">        url = BASE_URL + path + <span class="string">'?'</span> + urlencode(params)</span><br><span class="line">        logger.info(url)</span><br><span class="line">        data = json.dumps(payload, ensure_ascii=<span class="keyword">False</span>).encode(<span class="string">'utf-8'</span>)  <span class="comment"># 对于中文内容，要使用ensure_ascii=False</span></span><br><span class="line">        response = self.session.post(url, data=data).json()</span><br><span class="line">        logger.info(response)</span><br><span class="line">        <span class="keyword">return</span> response</span><br></pre></td></tr></table></figure>
<h1 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h1><ul>
<li>当有多个请求token同时过期，就会同时触发多个refresh</li>
<li>返回多个token，但只有最后一个token是可用的</li>
<li>其他请求token认证再次失败，再次同时触发多个refresh</li>
</ul>
<h1 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h1><ul>
<li>使用redis缓存token，定时刷新token</li>
<li>请求如果token过期，直接报错，不再触发刷新机制</li>
<li>将多节点刷新token，变为单节点刷新token</li>
</ul>
<h1 id="引入的新问题"><a href="#引入的新问题" class="headerlink" title="引入的新问题"></a>引入的新问题</h1><ul>
<li>需要维护redis和定时任务</li>
<li>如果修改了appid或secret，需要主动触发token刷新</li>
</ul>
<h1 id="改进的技术"><a href="#改进的技术" class="headerlink" title="改进的技术"></a>改进的技术</h1><ul>
<li>django + celery + redis，使用celery管理定时任务</li>
<li>django + action，使用django后台，在修改appid或secret之后，主动触发刷新</li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/03/22/python连接mysql/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/03/22/python连接mysql/" class="post-title-link" itemprop="url">python连接mysql</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-03-22 10:36:33" itemprop="dateCreated datePublished" datetime="2019-03-22T10:36:33+08:00">2019-03-22</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/开发/" itemprop="url" rel="index"><span itemprop="name">开发</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/03/22/python连接mysql/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/03/22/python连接mysql/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/03/22/python连接mysql/" class="leancloud_visitors" data-flag-title="python连接mysql">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><ul>
<li>python3已经成为主流，python2基本不再使用。</li>
<li>无论是开发环境还是生产环境，mysql都是不二选择。</li>
<li>mysql版本一直保持稳定更新，性能和功能也在不断加强。</li>
</ul>
<h1 id="Driver"><a href="#Driver" class="headerlink" title="Driver"></a>Driver</h1><ol>
<li><a href="https://pypi.org/project/mysqlclient/" target="_blank" rel="noopener">mysqlclient</a><ul>
<li>速度快，使用C，安装有依赖</li>
<li>生产环境下推荐使用</li>
</ul>
</li>
<li><a href="https://pypi.org/project/PyMySQL/" target="_blank" rel="noopener">PyMySQL</a><ul>
<li>纯python实现，安装使用简单</li>
<li>当安装mysqlclient失败的时候使用</li>
</ul>
</li>
</ol>
<h1 id="ORM"><a href="#ORM" class="headerlink" title="ORM"></a>ORM</h1><ol>
<li><a href="https://pypi.org/project/SQLAlchemy/" target="_blank" rel="noopener">SQLAlchemy</a><ul>
<li>ORM的第一选择</li>
<li>对于各种DB的各种Driver都有很好的支持</li>
</ul>
</li>
<li><a href="https://pypi.org/project/peewee/" target="_blank" rel="noopener">peewee</a><ul>
<li>非常轻量，API类似Django ORM</li>
<li>如果原有技术栈基于Django，可以使用。</li>
</ul>
</li>
</ol>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/03/08/dubbo错误跟踪/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/03/08/dubbo错误跟踪/" class="post-title-link" itemprop="url">dubbo错误跟踪</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-03-08 10:30:09" itemprop="dateCreated datePublished" datetime="2019-03-08T10:30:09+08:00">2019-03-08</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/运维/" itemprop="url" rel="index"><span itemprop="name">运维</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/03/08/dubbo错误跟踪/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/03/08/dubbo错误跟踪/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/03/08/dubbo错误跟踪/" class="leancloud_visitors" data-flag-title="dubbo错误跟踪">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="起因"><a href="#起因" class="headerlink" title="起因"></a>起因</h1><ul>
<li>发版的时候，应用报错</li>
</ul>
<h1 id="简单排查"><a href="#简单排查" class="headerlink" title="简单排查"></a>简单排查</h1><ul>
<li>在停止了dubbo之后，立刻停止service，错误随之而来。</li>
<li>两种可能：1、dubbo没有停掉；2、停止service时，应用自身错误</li>
</ul>
<h2 id="其他信息"><a href="#其他信息" class="headerlink" title="其他信息"></a>其他信息</h2><ul>
<li>两台同样的主机，同时执行，只有一台出错。</li>
<li>四个主机组成的集群，一次发版过程中，只有一台出错。</li>
<li>发版系统只发生过启动dubbo失败，没有发生过停止dubbo失败。</li>
</ul>
<h2 id="之前类似的错误"><a href="#之前类似的错误" class="headerlink" title="之前类似的错误"></a>之前类似的错误</h2><ul>
<li>因为dubbo名称和应用名称不一致，导致停止dubbo的时候，没有找到dubbo，导致没有停dubbo，直接停应用。</li>
<li>此种情况下，如果操作的是服务提供者应用A，那么，报错的应该是服务消费者B，C等</li>
<li>而此次报错，停止的是服务提供者应用A，报错的依旧是服务提供者应用A。</li>
</ul>
<h1 id="查错"><a href="#查错" class="headerlink" title="查错"></a>查错</h1><p>分析ELK日志，主机日志，查阅具体报错的java代码，询问具体开发人员</p>
<h2 id="分析ELK日志"><a href="#分析ELK日志" class="headerlink" title="分析ELK日志"></a>分析ELK日志</h2><ul>
<li>根据ELK的报错时间，结合发版系统的操作时间，发现跟停dubbo和停service有直接关系。</li>
<li>报错集中在同一个方法的同一行，初步怀疑是一个批量任务的for循环出错</li>
<li>错误：dubbo服务找不到。但是，是其他服务提供者的接口，即，此时应用作为一个消费者报错。</li>
</ul>
<h2 id="主机日志"><a href="#主机日志" class="headerlink" title="主机日志"></a>主机日志</h2><ul>
<li>因为发版时候的备份策略，以及应用日志的打印方式，导致主机日志在查错过程中，并没有起到应有作用。</li>
</ul>
<h2 id="具体java代码"><a href="#具体java代码" class="headerlink" title="具体java代码"></a>具体java代码</h2><ul>
<li>LTS定时任务，每三天的晚上1点执行。</li>
</ul>
<h2 id="开发人员"><a href="#开发人员" class="headerlink" title="开发人员"></a>开发人员</h2><ul>
<li>定时任务出错，之后任务会再次执行，没有影响</li>
<li>此定时任务执行需要很久时间，期间停service，自然会出错。</li>
</ul>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><ul>
<li>运维可以根据ELK错误日志，以及自身的操作日志，发现并排查出问题的50%以上内容</li>
<li>错误可以类比，但具体到个例，就必须看具体的错误，如果能看懂java代码，可以具体到那个功能出错。</li>
<li>引发错误的原因很多，甚至有可能是共同作用。</li>
<li>应该先把所有的原因都罗列出来，而不能过早排除某种错误。</li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/01/30/windows搭建类unix开发环境/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/01/30/windows搭建类unix开发环境/" class="post-title-link" itemprop="url">windows搭建类unix开发环境</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-01-30 21:49:06" itemprop="dateCreated datePublished" datetime="2019-01-30T21:49:06+08:00">2019-01-30</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/运维/" itemprop="url" rel="index"><span itemprop="name">运维</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/01/30/windows搭建类unix开发环境/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/01/30/windows搭建类unix开发环境/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/01/30/windows搭建类unix开发环境/" class="leancloud_visitors" data-flag-title="windows搭建类unix开发环境">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="背景介绍"><a href="#背景介绍" class="headerlink" title="背景介绍"></a>背景介绍</h1><ul>
<li>运维开发的项目很多，其中有部分python和go的项目，依赖的类库不支持windows。（如kafka，ansible）</li>
<li>日常工作依赖的企业微信，WPS办公软件，keepass等，离不开windows。</li>
<li>综上，需要在windows系统中，打造类unix开发环境</li>
</ul>
<h1 id="系统要求"><a href="#系统要求" class="headerlink" title="系统要求"></a>系统要求</h1><ul>
<li>windows 10 最新版本</li>
<li>开启WSL功能，并安装ubuntu，启动，设置用户名密码</li>
</ul>
<h1 id="使用软件"><a href="#使用软件" class="headerlink" title="使用软件"></a>使用软件</h1><ul>
<li>mobaxterm，免费版本即可</li>
</ul>
<h1 id="具体步骤"><a href="#具体步骤" class="headerlink" title="具体步骤"></a>具体步骤</h1><h2 id="1、准备工作"><a href="#1、准备工作" class="headerlink" title="1、准备工作"></a>1、准备工作</h2><ul>
<li>mobaxterm会自动识别WSL安装的ubuntu,，创建一个默认配置的WSL session即可。</li>
<li>使用国内ubuntu源，加速接下来的软件安装。常用的有：清华，阿里云，网易，中科大</li>
<li><a href="https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/" target="_blank" rel="noopener">清华大学镜像站</a><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak</span><br><span class="line">sudo vim /etc/apt/sources.list</span><br><span class="line">sudo apt-get update</span><br><span class="line">sudo apt-get upgrade</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="2、安装vscode"><a href="#2、安装vscode" class="headerlink" title="2、安装vscode"></a>2、安装vscode</h2><ul>
<li><p>在官网下载ubuntu版最新deb包</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">sudo dpkg -i /path/to/code/deb <span class="comment"># 会失败，然后执行下面命令，安装所需依赖</span></span><br><span class="line">sudo apt install -f <span class="comment"># 安装依赖</span></span><br><span class="line"> </span><br><span class="line"><span class="comment"># 需要安装其他依赖</span></span><br><span class="line">sudo apt install libgtk2.0-0 libxss1 libasound2 -y</span><br><span class="line"> </span><br><span class="line"><span class="comment"># 然后，在任意一个项目根目录</span></span><br><span class="line">code .</span><br><span class="line"><span class="comment"># 或者直接，即可看到vscode界面</span></span><br><span class="line">code</span><br></pre></td></tr></table></figure>
</li>
<li><p>此时，窗口不能移动，不能全屏，还存在中文字体，以及中文输入法问题。（并非乱码，而是fonts问题）</p>
</li>
<li>但是已经能够安装插件，代码高亮，跳转等正常开发功能了</li>
</ul>
<h2 id="3、安装xfce4"><a href="#3、安装xfce4" class="headerlink" title="3、安装xfce4"></a>3、安装xfce4</h2><ul>
<li><p>wsl默认使用ubuntu-server，没有桌面，安装一个轻量级桌面xfce4即可</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install xfce4</span><br></pre></td></tr></table></figure>
</li>
<li><p>然后再新建一个图形化的session，具体配置如下图<br><img src="/images/session.png" alt="session"></p>
</li>
<li>然后安装配置输入法（推荐fcitx + google拼音输入法）<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt-get --assume-yes install fcitx fcitx-googlepinyin dbus-x11</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="4、开发环境"><a href="#4、开发环境" class="headerlink" title="4、开发环境"></a>4、开发环境</h2><ul>
<li><p>go直接使用源码</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz</span><br><span class="line">sudo tar -C /usr/<span class="built_in">local</span>/ -xzf go1.11.5.linux-amd64.tar.gz</span><br></pre></td></tr></table></figure>
</li>
<li><p>python系统自带python3（python3.6）</p>
</li>
<li>一般需要额外安装gcc， python3-venv，python3-dev等一系列开发依赖包<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install build-essential libssl-dev libffi-dev python3-dev</span><br><span class="line">sudo apt-get install python3-venv</span><br><span class="line"> </span><br><span class="line">sudo apt-get install pkg-config</span><br><span class="line">sudo apt-get install libmysqlclient-dev</span><br><span class="line"> </span><br><span class="line"><span class="comment"># 高端shell</span></span><br><span class="line">sudo apt-get install zsh</span><br><span class="line">sh -c <span class="string">"<span class="variable">$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)</span>"</span></span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="5、最终效果"><a href="#5、最终效果" class="headerlink" title="5、最终效果"></a>5、最终效果</h2><ul>
<li>项目代码可以直接使用windows下原有代码，配置好go path， venv等环境即可<br><img src="/images/desktop.png" alt="desktop"> </li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/01/16/django服务器地址/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/01/16/django服务器地址/" class="post-title-link" itemprop="url">django服务器地址</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-01-16 18:45:08" itemprop="dateCreated datePublished" datetime="2019-01-16T18:45:08+08:00">2019-01-16</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/开发/" itemprop="url" rel="index"><span itemprop="name">开发</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/01/16/django服务器地址/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/01/16/django服务器地址/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/01/16/django服务器地址/" class="leancloud_visitors" data-flag-title="django服务器地址">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="django地址"><a href="#django地址" class="headerlink" title="django地址"></a>django地址</h1><ul>
<li>request.build_absolute_uri</li>
<li>reverse</li>
<li>site get_current_site</li>
</ul>
<h1 id="nginx配置"><a href="#nginx配置" class="headerlink" title="nginx配置"></a>nginx配置</h1><ul>
<li>proxy</li>
<li>set_header</li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2019/01/15/travis部署page/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2019/01/15/travis部署page/" class="post-title-link" itemprop="url">travis部署page</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2019-01-15 16:25:00" itemprop="dateCreated datePublished" datetime="2019-01-15T16:25:00+08:00">2019-01-15</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/运维/" itemprop="url" rel="index"><span itemprop="name">运维</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2019/01/15/travis部署page/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2019/01/15/travis部署page/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2019/01/15/travis部署page/" class="leancloud_visitors" data-flag-title="travis部署page">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="个人博客简介"><a href="#个人博客简介" class="headerlink" title="个人博客简介"></a>个人博客简介</h1><ul>
<li>使用hexo框架：先用markdown编写，然后渲染成html—+css+js的静态网站</li>
<li><code>source</code>目录下，是markdown文件，可以认为是程序源码。</li>
<li><code>public</code>目录下，是编译好的网站，可以看做可执行程序。</li>
</ul>
<h1 id="使用travis的背景"><a href="#使用travis的背景" class="headerlink" title="使用travis的背景"></a>使用travis的背景</h1><ul>
<li>使用hexo引擎+next主题搭建的个人博客静态网站，本身可以很方便的deploy到github的page页面。但是不方便国内访问，所以需要在国内vps部署一份。</li>
<li>写blog可能在各种环境：家里，公司，或者直接在vps上面。此时，markdown文件的同步以及版本管理，就成了问题。</li>
<li>综上，在github上面创建两个项目：<ul>
<li>page项目存放生成的html等静态文件，可以直接访问。</li>
<li>源文件项目存放hexo创建的目录，包括所有的source，theme，image等，方便在各个环境下编写blog</li>
</ul>
</li>
<li>使用travis自动部署</li>
</ul>
<h1 id="使用travis方法"><a href="#使用travis方法" class="headerlink" title="使用travis方法"></a>使用travis方法</h1><ul>
<li>保存markdown源文件</li>
<li>自动build push</li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2018/04/17/samba搭建/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2018/04/17/samba搭建/" class="post-title-link" itemprop="url">samba搭建</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-04-17 14:26:24" itemprop="dateCreated datePublished" datetime="2018-04-17T14:26:24+08:00">2018-04-17</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/运维/" itemprop="url" rel="index"><span itemprop="name">运维</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2018/04/17/samba搭建/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2018/04/17/samba搭建/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2018/04/17/samba搭建/" class="leancloud_visitors" data-flag-title="samba搭建">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h1 id="在centos上，安装samba"><a href="#在centos上，安装samba" class="headerlink" title="在centos上，安装samba"></a>在centos上，安装samba</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install samba samba-client –y</span><br></pre></td></tr></table></figure>
<h1 id="创建系统用户"><a href="#创建系统用户" class="headerlink" title="创建系统用户"></a>创建系统用户</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">useradd -g samba-group -s /sbin/nologin smb01</span><br></pre></td></tr></table></figure>
<h1 id="将系统用户加入samba并设置密码"><a href="#将系统用户加入samba并设置密码" class="headerlink" title="将系统用户加入samba并设置密码"></a>将系统用户加入samba并设置密码</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pdbedit -a smb01</span><br></pre></td></tr></table></figure>
<h1 id="设置SELinux权限问题"><a href="#设置SELinux权限问题" class="headerlink" title="设置SELinux权限问题"></a>设置SELinux权限问题</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">setsebool -P samba_export_all_rw on</span><br></pre></td></tr></table></figure>
<h1 id="启动服务"><a href="#启动服务" class="headerlink" title="启动服务"></a>启动服务</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service smb start</span><br></pre></td></tr></table></figure>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2018/01/19/mysql备份/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2018/01/19/mysql备份/" class="post-title-link" itemprop="url">mysql备份</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-01-19 17:40:19" itemprop="dateCreated datePublished" datetime="2018-01-19T17:40:19+08:00">2018-01-19</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/运维/" itemprop="url" rel="index"><span itemprop="name">运维</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2018/01/19/mysql备份/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2018/01/19/mysql备份/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2018/01/19/mysql备份/" class="leancloud_visitors" data-flag-title="mysql备份">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="mysql的备份"><a href="#mysql的备份" class="headerlink" title="mysql的备份"></a>mysql的备份</h3><p><a href="https://dev.mysql.com/doc/refman/5.7/en/backup-and-recovery.html" target="_blank" rel="noopener">mysql官方文档</a></p>
<h3 id="使用mysql自带的工具：mysqldump"><a href="#使用mysql自带的工具：mysqldump" class="headerlink" title="使用mysql自带的工具：mysqldump"></a>使用mysql自带的工具：mysqldump</h3><p><a href="https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html" target="_blank" rel="noopener">mysqldump</a></p>
<h3 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ mysqldump --defaults-extra-file=/root/backup/config.cnf --databases cmdb | gzip &gt; /root/backup/$(date +%Y_%m_%d_%H_%M_%S)_cmdb.sql.gz</span><br></pre></td></tr></table></figure>
<p>其中的config.cnf</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">[client]</span></span><br><span class="line">    <span class="string">user</span> <span class="string">=</span> <span class="string">user</span></span><br><span class="line">    <span class="string">password</span> <span class="string">=</span> <span class="string">user_passwd</span></span><br><span class="line">    <span class="string">host</span> <span class="string">=</span> <span class="string">localhost</span></span><br></pre></td></tr></table></figure>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2017/12/14/git打补丁/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2017/12/14/git打补丁/" class="post-title-link" itemprop="url">git打补丁</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2017-12-14 14:09:55" itemprop="dateCreated datePublished" datetime="2017-12-14T14:09:55+08:00">2017-12-14</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/开发/" itemprop="url" rel="index"><span itemprop="name">开发</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2017/12/14/git打补丁/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2017/12/14/git打补丁/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2017/12/14/git打补丁/" class="leancloud_visitors" data-flag-title="git打补丁">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><ul>
<li>有时候，我们需要把第三方库的一些更新，合并到我们的代码里面。</li>
<li>我们可以生成一个patch，并进行apply</li>
</ul>
<h2 id="生成补丁"><a href="#生成补丁" class="headerlink" title="生成补丁"></a>生成补丁</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git format-patch -1 &lt;sha&gt;</span><br><span class="line">$ git format-patch -1 HEAD</span><br><span class="line">$ git diff &lt;sha2&gt; &lt;sha1&gt; &gt; mypatch.diff</span><br></pre></td></tr></table></figure>
<h2 id="打补丁"><a href="#打补丁" class="headerlink" title="打补丁"></a>打补丁</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ git apply &lt;patch&gt;</span><br></pre></td></tr></table></figure>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://lvsmart.cn/2017/12/12/svg-icon使用/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Lvsmart">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="旅行者">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                
                <a href="/2017/12/12/svg-icon使用/" class="post-title-link" itemprop="url">svg-icon使用</a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2017-12-12 17:44:05" itemprop="dateCreated datePublished" datetime="2017-12-12T17:44:05+08:00">2017-12-12</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2019-07-27 23:28:59" itemprop="dateModified" datetime="2019-07-27T23:28:59+08:00">2019-07-27</time>
              
            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing"><a href="/categories/开发/" itemprop="url" rel="index"><span itemprop="name">开发</span></a></span>

                
                
              
            </span>
          

          
            
            
              
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
            
                <a href="/2017/12/12/svg-icon使用/#comments" itemprop="discussionUrl">
                  <span class="post-meta-item-text">评论数：</span> <span class="post-comments-count valine-comment-count" data-xid="/2017/12/12/svg-icon使用/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
            <span id="/2017/12/12/svg-icon使用/" class="leancloud_visitors" data-flag-title="svg-icon使用">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              
                <span class="post-meta-item-text">阅读次数：</span>
              
                <span class="leancloud-visitors-count"></span>
            </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="svg"><a href="#svg" class="headerlink" title="svg"></a>svg</h2><ul>
<li>Scalable Vector Graphics</li>
<li>可缩放矢量图形</li>
<li>基于XML格式</li>
</ul>
<p>如: circle.svg</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">svg</span> <span class="attr">width</span>=<span class="string">"100"</span> <span class="attr">height</span>=<span class="string">"100"</span>&gt;</span></span><br><span class="line">   <span class="tag">&lt;<span class="name">circle</span> <span class="attr">cx</span>=<span class="string">"50"</span> <span class="attr">cy</span>=<span class="string">"50"</span> <span class="attr">r</span>=<span class="string">"40"</span> <span class="attr">stroke</span>=<span class="string">"green"</span> <span class="attr">stroke-width</span>=<span class="string">"4"</span> <span class="attr">fill</span>=<span class="string">"yellow"</span>/&gt;</span></span><br><span class="line">   Sorry, your browser does not support inline SVG.</span><br><span class="line"><span class="tag">&lt;/<span class="name">svg</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="优点"><a href="#优点" class="headerlink" title="优点"></a>优点</h2><ul>
<li>可用文本编辑器直接编辑</li>
<li>可任意缩放</li>
<li>可在任何分辨率下，被高质量打印</li>
<li>可在图像质量不下降的情况下，被放大</li>
</ul>
<h2 id="使用——svg-sprite"><a href="#使用——svg-sprite" class="headerlink" title="使用——svg sprite"></a>使用——svg sprite</h2><ul>
<li><a href="http://www.zhangxinxu.com/wordpress/2014/07/introduce-svg-sprite-technology/" target="_blank" rel="noopener">未来必热：SVG Sprite技术介绍</a></li>
</ul>

          
        
      
    </div>

    

    
    
    

    

    
      
    
    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <div class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="Lvsmart">
            
              <p class="site-author-name" itemprop="name">Lvsmart</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">28</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">4</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">43</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          

          
          

          
            
          
          

        </div>
      </div>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">  <a href="http://www.miitbeian.gov.cn" rel="noopener" target="_blank">粤ICP备19008848号 </a>&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Lvsmart</span>

  

  
</div>


  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.8.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> v6.7.0</div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

    

    
  </div>

  

<script>
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>





  



  






  













  



  
  <script src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js"></script>

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script>

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.1/velocity.min.js"></script>

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.1/velocity.ui.min.js"></script>

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.6/jquery.fancybox.min.js"></script>

  
  <script src="//cdn.jsdelivr.net/gh/theme-next/theme-next-reading-progress@1/reading_progress.min.js"></script>


  


  <script src="/js/src/utils.js?v=6.7.0"></script>

  <script src="/js/src/motion.js?v=6.7.0"></script>



  
  


  <script src="/js/src/schemes/muse.js?v=6.7.0"></script>



  

  


  <script src="/js/src/bootstrap.js?v=6.7.0"></script>



  
  

  

<script src="//cdn.jsdelivr.net/npm/leancloud-storage@3/dist/av-min.js"></script>



  

<script src="//cdnjs.cloudflare.com/ajax/libs/valine/1.3.4/Valine.min.js"></script>

<script>
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail,link';
  guest = guest.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#comments',
    verify: false,
    notify: false,
    appId: 'FW7Kv07IzB8TH4JCw12qXqGA-gzGzoHsz',
    appKey: '604WAxYe0JbDt9D0hfqOnEjl',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: true
  });
</script>





  





  

  

  

  

  

  

  

  

  

  

  

  

  

</body>
</html>
